Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed import of AWS - reduce code size #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sean9keenan
Copy link

@sean9keenan sean9keenan commented Oct 10, 2017

Pulled out the S3 dependency, and imported AWS directly from aws-sdk/global.

This makes it possible for webpack to minimize the AWS SDK as the other dependencies don't even enter the picture.

The net impact for me was reducing the javascript file that is downloaded from 1.9MB to 788KB, which was a pretty big win in my book! (Specifically the aws-sdk is now 216KB vs 1.3MB)

Although I'll be honest - it took me longer than I care to admit to find this particular incantation to reduce the bundle size... 😄

For future people that might read this:

  • Using their minimized SDK was a dead-end, as it would require altering the webpack file from the CreateReactApp, which is possible - but makes it harder to get upstream changes since you'd have to eject
  • Attempting to import pieces piece-wise as named exports a la import { Config, CognitoIdentityCredentials } from 'aws-sdk'. Completely works - you just have to pass the Config manually into the second arg of CognitoIdentityCredentials, as well as change the region on the config directly as a property, but alas this doesn't let Webpack minimize the sdk properly.

Pulled out the S3 dependency, and imported AWS directly from aws-sdk/global
@jayair
Copy link
Member

jayair commented Oct 11, 2017

@sean9keenan Nice work! This is something we should add to the tutorial. Did you find any documentation for this on AWS' side? We'd want to link to that in the tutorial as well.

@jayair
Copy link
Member

jayair commented Oct 12, 2017

@sean9keenan Great! Thanks. I'll take a look and figure out how to integrate it with the tutorial.

@quantuminformation
Copy link

thx @sean9keenan

@jayair
Copy link
Member

jayair commented Dec 30, 2017

@sean9keenan I added a section in the Deploy chapter on your PR and linked to it as well - https://serverless-stack.com/chapters/deploy-to-s3.html#app-bundle-size

Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants